package com.yanqu.road.server.cmd.activity.unionwar;

import com.yanqu.road.pb.activity.unionwar.UnionWarActivityServerProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.unionwar.UnionPhaseWarMgr;
import com.yanqu.road.server.manger.activity.unionwar.UnionWar;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_UNION_WAR_ACTIVITY_GET_GUESS_LIST, desc = "获取群英争霸竞猜列表")
public class UnionWarGetGuessListCmd extends AbstractCommand {
    private int activityId;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        UnionWarActivityServerProto.GetUnionWarGuessListReqMsg msg = UnionWarActivityServerProto.GetUnionWarGuessListReqMsg.parseFrom(packet.getBytes());
        activityId = msg.getActivityId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData(GamePlayer player) {
        UnionWarActivityServerProto.GetUnionWarGuessListRespMsg.Builder respMsg = UnionWarActivityServerProto.GetUnionWarGuessListRespMsg.newBuilder();
        UnionWar unionWar = UnionPhaseWarMgr.getUnionWar(activityId);
        if (unionWar != null) {
            unionWar.syncGuessListMsg(player);
        }
        player.sendPacket(ClientProtocol.U_UNION_WAR_ACTIVITY_GET_GUESS_LIST, respMsg);
    }
}
